package com.onepiece.shipelves.common.ticker;

/**
 * @author guoyanjiang
 * @date 2019-04-03
 */
public class BaseExchangePair {

    private String exchangeKey;

    //symbol + currency
    private String tickerPair;

    //symbol + currency
    private BaseTickerPair baseTickerPair;

    //取自ticker的要用currency.在我们自己系统中流转要用这个，不能用currency;
    private String currencyShow;

    private String coinKey;

    //1现货，2期货
    private Integer tradeType = 1;

    public BaseExchangePair() {
    }

    public BaseExchangePair(String exchangeKey, String coinKey, String tickerPair, BaseTickerPair baseTickerPair, String currencyShow) {
        this.exchangeKey = exchangeKey;
        this.tickerPair = tickerPair;
        this.baseTickerPair = baseTickerPair;
        this.currencyShow = currencyShow;
        this.coinKey = coinKey;
    }

    public BaseExchangePair(String exchangeKey, String coinKey, String tickerPair, String currencyShow) {
        this.exchangeKey = exchangeKey;
        this.tickerPair = tickerPair;
        this.baseTickerPair = new BaseTickerPair(tickerPair);
        this.currencyShow = currencyShow;
        this.coinKey = coinKey;
    }

    public BaseExchangePair(String exchangeKey, String coinKey, String tickerPair, String currencyShow, Integer tradeType) {
        this.exchangeKey = exchangeKey;
        this.tickerPair = tickerPair;
        this.baseTickerPair = new BaseTickerPair(tickerPair);
        this.tradeType = tradeType;
        this.currencyShow = currencyShow;
        this.coinKey = coinKey;
    }

    public BaseExchangePair(String exchangeKey, BaseTickerPair baseTickerPair) {
        this.exchangeKey = exchangeKey;
        this.baseTickerPair = baseTickerPair;
        this.tickerPair = baseTickerPair.providePairStr();
    }

    public void setExchangeKey(String exchangeKey) {
        this.exchangeKey = exchangeKey;
    }

    public String getExchangeKey() {
        return exchangeKey;
    }

    public String getTickerPair() {
        return tickerPair;
    }

    public void setTickerPair(String tickerPair) {
        this.tickerPair = tickerPair;
    }

    //提供用于在ticker中获取信息的exchangeKey
    public String provideTickerExchangeKey() {
        return exchangeKey;
    }

    //提供用于在ticker中获取信息的pair
    public String provideTickerPair() {
        return tickerPair;
    }

    public String provideFullPair() {
        return String.format("%s_%s", exchangeKey, provideTickerPair());
    }

    //提供用于在ticker中获取信息的currency
    public String provideTickerCurrency() {
        return provideCoinCurrencyUnitInPair();
    }

    public String provideCoinSymbolInPair() {
        return baseTickerPair.getSymbol();
    }

    public String provideCoinCurrencyUnitInPair() {
        return baseTickerPair.getCurrencyUnit();
    }


    public Integer getTradeType() {
        return tradeType;
    }

    public void setTradeType(Integer tradeType) {
        this.tradeType = tradeType;
    }

    public boolean isFuture() {
        return this.tradeType == 2;
    }

    public String getCurrencyShow() {
        return currencyShow;
    }

    public void setCurrencyShow(String currencyShow) {
        this.currencyShow = currencyShow;
    }

    public String getCoinKey() {
        return coinKey;
    }

    public void setCoinKey(String coinKey) {
        this.coinKey = coinKey;
    }

    public BaseTickerPair getBaseTickerPair() {
        return baseTickerPair;
    }

    public void setBaseTickerPair(BaseTickerPair baseTickerPair) {
        this.baseTickerPair = baseTickerPair;
    }

}
